<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.sql.*"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Account List</title>
</head>
<body bgcolor="red">
	<center> <h2>  Account List </h2> </center>
	<br>
	<% 
		String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
		String connectionURL = "jdbc:odbc:bookstore";
		String username = "sa";
		String password = "tung";
		String sqlQuery = "select * from account";
		Class.forName(driverName).newInstance();
		Connection con = DriverManager.getConnection(connectionURL);
		Statement statement = con.createStatement();
		ResultSet rs = statement.executeQuery(sqlQuery);
	%>
	<center> 
		<table border="1">
		<tr>
		<% 
			ResultSetMetaData rsmd = rs.getMetaData();
			int columnCount = rsmd.getColumnCount();
			for (int i=0; i<columnCount; i++) {
		%>
			<th> <%=rsmd.getColumnLabel(i+1)%> </th>
		<% 
			}
		%>
		</tr>
		<%
			while (rs.next()) {
		%>
		<tr> 
		<%
			for (int i=0; i<columnCount; i++) {
		%>
			<td> <%=rs.getString(i+1) %> </td>
		<%
			}
		%>
		</tr>
		<%
			}
		%>
		</table>
	
	</center>
</body>
</html>